//
//  VIZNoteController.m
//  Young-Old
//
//  Created by 位立志 on 16/4/26.
//  Copyright © 2016年 位立志. All rights reserved.
//

#import "VIZNoteController.h"

@interface VIZNoteController ()

@property(nonatomic,weak)UISegmentedControl *titleSegment;

@end

@implementation VIZNoteController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIView randomColor];
    
    [self setSegmentTitle];
    
}

//设置UISegmentedControl头
- (void)setSegmentTitle{
    
    UISegmentedControl *titleSegment = [[UISegmentedControl alloc]initWithItems:@[@"我的",@"好友"]];
    self.titleSegment = titleSegment;
    titleSegment.selectedSegmentIndex = 0;
    [self.navigationController.view addSubview:titleSegment];
    NSNumber *widthValue = [[NSNumber alloc]initWithFloat:(self.view.frame.size.width)/2];
    
    [titleSegment makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.navigationController.view);
        make.top.equalTo(self.navigationController.view.top).offset(25);
        make.width.equalTo(widthValue);
    }];
    
    [titleSegment addTarget:self action:@selector(titleSegmentValueChanged) forControlEvents:UIControlEventValueChanged];

}

- (void)titleSegmentValueChanged{
    
    VIZVistorViewController *vistorController = [[VIZVistorViewController alloc]init];
    
    switch (self.titleSegment.selectedSegmentIndex) {
        case 0:
        {
#warning 麻蛋,无法隐藏返回按钮
            [self.navigationController popToRootViewControllerAnimated:YES];
            self.navigationItem.hidesBackButton = YES;
            break;
        }
        case 1:
        {
#warning 麻蛋,无法隐藏返回按钮
            [self.navigationController pushViewController:vistorController animated:YES];
            self.navigationItem.hidesBackButton = YES;

            break;
        }
        default:
            break;
    }
    
    
}








@end
